import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { resolve } from "path";
import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
import AutoImport from "unplugin-auto-import/vite";
import eslintPlugin from "vite-plugin-eslint";
function pathResolve(dir: string) {
	return resolve(process.cwd(), ".", dir);
}
// https://vitejs.dev/config/
export default defineConfig({
	base: "./",
	build: {
		outDir: "superAI",
	},
	plugins: [
		vue(),
		eslintPlugin({
			include: ["src/**/*.ts", "src/**/*.vue", "src/*.ts", "src/*.vue"],
		}),
		createSvgIconsPlugin({
			// 指定需要缓存的图标文件夹
			iconDirs: [resolve(process.cwd(), "src/assets/icons")],
			// 指定symbolId格式
			symbolId: "icon-[dir]-[name]",
		}),
		AutoImport({
			include: [/\.[tj]sx?$/, /\.vue$/, /\.vue\?vue/, /\.md$/],
			imports: [
				// 插件预设支持导入的api
				"vue",
				"vue-router",
			],
		}),
	],
	resolve: {
		alias: [
			{
				find: "vue-i18n",
				replacement: "vue-i18n/dist/vue-i18n.cjs.js",
			},
			// /@/xxxx => src/xxxx
			{
				find: /@\//,
				replacement: pathResolve("src") + "/",
			},
			{
				find: /@cps\//,
				replacement: pathResolve("src") + "/components/",
			},
			{
				find: /@page\//,
				replacement: pathResolve("src") + "/views/layout/",
			},
			{
				find: /@img\//,
				replacement: pathResolve("src") + "/assets/images/",
			},
			// /#/xxxx => types/xxxx
			{
				find: /#\//,
				replacement: pathResolve("types") + "/",
			},
		],
	},
	server: {
		port: 4488,
		proxy: {
			//*开发服务器跨域
			"/api": {
				// target: "http://192.168.0.67:19089/superAI",
				// target: "http://113.57.78.20:38010/superService/superAI",
				// target: "http://113.57.78.21:19089/superAI",
				target : "http://113.57.78.20:38040/superAI",
				rewrite: (path) => path.replace(/^\/api/, ""),
			},
		},
	},
	define: {
		__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: true,
	},
});
